﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterPage6 : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Membership.GetUser() != null)
        {
            string strUserName = Membership.GetUser().ToString();
            if (Session.Count <= 0)
            {
                
                SqlConnection objConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["smsConnectionString"].ConnectionString);

                DataSet ds = new DataSet();
                SqlDataAdapter da = new SqlDataAdapter("select RoleName from aspnet_Users,aspnet_Roles,aspnet_UsersInRoles where aspnet_Users.UserId =aspnet_UsersInRoles. UserId and aspnet_UsersInRoles.RoleId = aspnet_Roles.RoleId and UserName = '" + strUserName + "'", objConnection);
                da.Fill(ds, "StaffinfoRole");
                DataTable dt1 = ds.Tables["StaffinfoRole"];

                ArrayList al = new ArrayList();
                for (int i = 0; i < dt1.Rows.Count; i++)
                    al.Add(dt1.Rows[i].ItemArray[0]);

                Session["Role"] = al;
            }

        }
    }
}
